(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/cases/graphics/example/linejoin.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '23e05St68tC7aM880aEaUaS', 'linejoin', __filename);
// cases/graphics/example/linejoin.js

"use strict";

var LineJoin = cc.Graphics.LineJoin;
var LineCap = cc.Graphics.LineCap;

cc.Class({
    extends: cc.Component,

    properties: {},

    // use this for initialization
    onLoad: function onLoad() {
        if (cc.director.setClearColor) {
            cc.director.setClearColor(cc.Color.WHITE);
        }

        this.graphics = this.getComponent(cc.Graphics);
        this.graphics.lineWidth = 20;

        this.time = 0;
        this.radius = 100;

        this.draw();
    },

    onDisable: function onDisable() {
        if (cc.director.setClearColor) {
            cc.director.setClearColor(cc.Color.BLACK);
        }
    },

    // called every frame, uncomment this function to activate update callback
    update: function update(dt) {
        this.time += dt * 0.5;
        this.draw();
    },

    draw: function draw() {
        var graphics = this.graphics;
        graphics.clear();

        var rx = this.radius * Math.sin(this.time);
        var ry = -this.radius * Math.cos(this.time);

        // line join
        graphics.lineCap = LineCap.BUTT;

        graphics.lineJoin = LineJoin.BEVEL;
        this.drawLine(-200, 0, rx, ry);

        graphics.lineJoin = LineJoin.MITER;
        this.drawLine(0, 0, rx, ry);

        graphics.lineJoin = LineJoin.ROUND;
        this.drawLine(200, 0, rx, ry);

        // line cap
        graphics.lineJoin = LineJoin.MITER;

        graphics.lineCap = LineCap.BUTT;
        this.drawLine(0, -125, rx, ry);

        graphics.lineCap = LineCap.SQUARE;
        this.drawLine(-200, -125, rx, ry);

        graphics.lineCap = LineCap.ROUND;
        this.drawLine(200, -125, rx, ry);
    },

    drawLine: function drawLine(x, y, rx, ry) {
        var graphics = this.graphics;

        graphics.moveTo(x + rx, y + ry);
        graphics.lineTo(x, y);
        graphics.lineTo(x - rx, y + ry);
        graphics.stroke();
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=linejoin.js.map
        